Release 10.1A: OpenEdge Development:
ProDataSets
Buffer BATCH-SIZE and LAST-BATCH attributes
If you want to use the
OFF-ENDevent to support transparently retrieving successive batches of data from the server, you need to be able to specify how many rows to fill the table with for each batch, and also signal when all the data from the Data-Source has been retrieved.The
BATCH-SIZEattribute on a ProDataSet temp-table buffer lets you determine how many rows to fill at a time. If you set this integer attribute to a non-zero value, then whenever you execute aFILLon that buffer or its ProDataSet, Progress copies no more thanBATCH-SIZErows from the Data-Source to the temp-table. If theBATCH-SIZEis reached before the end-of-data condition on the Data-Source, theFILLstops for that buffer.If the end of data is reached before the
BATCH-SIZEis exceeded, then Progress sets the buffer’s logical attributeLAST-BATCHto true. If the number of rows remaining to be read exactly matches the value ofBATCH-SIZE, Progress detects this and setsLAST-BATCHeven without attempting to position beyond the last row of data. In this way,LAST-BATCHis set correctly when the total number of rows that satisfy the buffer’s query is an exact multiple of theBATCH-SIZE.
LAST-BATCHis automatically set during the execution of theFILLmethod when theBATCH-SIZEon the buffer is non-zero and the end of the data is reached, and is cleared before the start of anyFILLorEMPTYactions on the same buffer or ProDataSet. If this default behavior is not satisfactory, it can be set programmatically, right after theFILLor in anAFTER-FILLevent.LAST-BATCHis always false whenBATCH-SIZEis zero or the Unknown value (?), which means that data batching is not being done.This attribute is marshaled along with the rest of the ProDataSet definition when the ProDataSet is passed as a parameter to another Progress procedure, whether local or remote. If you define an
OFF-ENDevent handler for the buffer in the other procedure, it can check theLAST-BATCHflag for the buffer and determine whether it should make a call to get more rows or if there are no more rows to retrieve. The "Setting up an event handler for the OFF-END query event" section shows an example of this.Batch-size is primarily intended to limit the number of rows added to a top buffer in a ProDataSet, or to a non-top buffer whose parent table normally has only one row in it. However, it can be set at any level of the hierarchy. The counter used to compare the rows read against the
Note: If there are multipleBATCH-SIZEfor a buffer is reset for everyFILLaction. If a buffer is not a top-level buffer in the ProDataSet, thenFILLmay be called on it many times, once for each parent row. TheBATCH-SIZElimit is applied anew each time. For example, if you havettCustandttOrderas parent and child, and you put aBATCH-SIZEof10onttOrder, then for eachttCustrecord that is added tottCustduring theFILL, you can have up to10ttOrderrecords added to the ProDataSet. Thus in a case such as this theBATCH-SIZEon the child table limits the number of child rows for each parent, not the total number of rows for theFILL.FILLson the same temp-table, either becauseFILLis invoked multiple times in succession, or becauseFILLis invoked on a buffer that is a child of some parent buffer in a ProDataSet and the parent buffer has more than one row, the value ofLAST-BATCHwill be true if the last invocation of theFILLfor that buffer reached the end of data, but false otherwise, and therefore cannot really be relied on. For example, let’s go back to the case of a ProDataSet withttCustandttOrdertables, and multipleCustomersand theirOrders being read in the sameFILL.If there is aBATCH-SIZEforttOrder, then within a single ProDataSetFILL, thatBATCH-SIZEmay be reached forOrders of someCustomersbut not for others.LAST-BATCHwill be true if the lastCustomerhad moreOrders than theBATCH-SIZEforttOrder, and false otherwise. This is why we say thatBATCH-SIZEis really intended for use on a top-level buffer, or on a child buffer when there is only one parent beingFILLedat a time.Though the
LAST-BATCHattribute is marshaled with the ProDataSet, theBATCH-SIZEis not marshaled as part of a ProDataSet remote or local parameter. This value must be set and kept on the server side. Normally the client will need to know the value ofLAST-BATCH, which is marshaled, but not be concerned about theBATCH-SIZE.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |